-
Notifications
You must be signed in to change notification settings - Fork 492
Conversation
bool WiFiManager::StartAP() { | ||
// Use arduino string, casting an int to std::string with arduino C++ support | ||
// isn't easy. | ||
String ssid("FireThing-"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a constant format string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best I can tell there is no easy printf support in arduino. We can use c printf but you need to allocate a buffer and do the manipulations there which is what I was avoiding by just using arduino's string and concatenation.
|
||
bool WiFiManager::StartAP() { | ||
// Use arduino string, casting an int to std::string with arduino C++ support | ||
// isn't easy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::to_string didn't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, not defined for some reason. There are other std:: things that arduino c++ doesn't support as well.
ssid += ESP.getChipId(); | ||
|
||
WiFi.mode(WIFI_AP_STA); | ||
if (!WiFi.softAP(ssid.c_str())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snould we retry if that fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller of this is free to retry on failure. I don't actually know what would cause this to fail.
String ssid("FireThing-"); | ||
ssid += ESP.getChipId(); | ||
|
||
WiFi.mode(WIFI_AP_STA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the mixed mode where we can be both client and station?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is this one. AP is access point and STA is wifi's wierd name for a client.
debug_((String("WiFi AP : ") + ssid).c_str()); | ||
debug_((String("Wifi AP IP : ") + WiFi.softAPIP().toString()).c_str()); | ||
|
||
dns_.reset(new DNSServer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that also doing dhcp or just dns? if the late could we return 8.8.8.8 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how you do a captive portal. You become the dns server and just return your own ip address for every lookup attempt. This is how WiFiManager (the arduino library) was doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to bring down the dns once the device is connected to wifi? Will it only get request from the WiFi AP network?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could leave it running indefinitely without any issues.
What DNS servers your computer uses is part of the settings that DHCP provides. So if you are a client of the esp's DHCP server you will get this as your dns server (I am not certain how this is specified actually as we never talk directly to the esp's dhcp server but it works). But if you are a client of another DHCP server, like if you are on GoogleGuest, than you will get their dns servers (probably 8.8.8.8, Google's dns server).
} | ||
|
||
debug_((String("WiFi AP : ") + ssid).c_str()); | ||
debug_((String("Wifi AP IP : ") + WiFi.softAPIP().toString()).c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you explore mdns support so that you don't have to rely on the IP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IP is actually always the same, it is hard coded to 192.168.4.1 . mdns would be great for when we are in station mode though, that way we can be configured all the time without having to access our captive portal. I haven't looked into it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great if we can have the same mdns name for STA and AP mode:
- the user connect to Firethings AP
- the captive portal redirect the user to firebase.local
- the user configure credentials and firethings connect to the wifi network
- the user reconnect to the home router AP
- the user refresh firebase.local and still access the same configuration UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that does sound pretty compelling. I spawned #233 to explore this, don't see any point blocking this PR on it though as this will be the basis for that work.
Going to merge anyway and carry on, nothing in the comments seems pressing. Feel free to continue commenting and we can do followups. |
This is working but there are some kinks that still need to be worked out with the whole system. I want to be able to cleanly keep the portal accessible while the user tests wifi settings. Currently this works if the network they wish to connect to and the Firething's network happen to be on the same channel. We should have a better story for what happens when they aren't.
This is the last major piece of the Firething, all we need to do now is store the Config in flash when updated. I will implement something for that next and do a lot more testing and tweaking.